
package com.craterhill.java.ems.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.craterhill.java.ems.common.beans.Staff;
import com.craterhill.java.ems.dao.StaffDao;
import com.craterhill.java.ems.service.StaffService;

@Service
public class StaffServiceImpl implements StaffService {

	@Autowired
	private StaffDao staffDao;

	@Override
	public Staff saveStaff(Staff staff) {
		int newStaffId = staffDao.save(staff);
		staff.setStaffId(newStaffId);
		return staff;
	}

	@Override
	public boolean updateStaff(Staff staff) {
		return staffDao.update(staff);
	}

	@Override
	public boolean deleteStaff(int staffId) {
		return staffDao.remove(staffId);
	}

	@Override
	public Staff getStaff(int staffId) {
		return staffDao.find(staffId);
	}

	@Override
	public List<Staff> getStaffList(int roleId) {
		return staffDao.findByRole(roleId);
	}
}
